M=2000;
N=0;

%Get the MNIST training data
[trainImg, trainLab] = getMNISTDigits(M,0);

for i=1:10
    
    imgs=[];
    imgs(:,:,1)=trainImg(:,:,i);
    
    labs=[];
    labs(1)=trainLab(i);
    
    nxt = 2;
    
    p=[1 2 Inf];
    
    for j=1:3
    
        [matchLabel matchImg] = bestMatch(i,trainImg,trainLab,...
                                          true,@lpNorm,p(j));
    
        imgs(:,:,nxt)=matchImg;
        labs(nxt)=matchLabel;
        
        nxt = nxt+1;
    end
    
    for j=0:1
    
        [matchLabel matchImg] = bestMatch(i,trainImg,trainLab,...
                                          false,@dotProduct,j);
    
        imgs(:,:,nxt)=matchImg;
        labs(nxt)=matchLabel;
        
        nxt = nxt+1;
    end
    
    %display match
    colLabels={'Ref','L1','L2','LInf','IP','IP Norm'};
    arrangeInGrid(imgs,labs,nxt-1,1,70,true,colLabels);
end